from tornado.web import Application, StaticFileHandler

import config
from environment import environment


class Application(Application):
    def __init__(self):
        # 初始化数据库、redis等,项目启动的时候，不要引入模型类
        environment.initialize() #会报错Specify 'extend_existing=True' to redefine options and columns on an existing Table object.
        # 接口注册
        environment.register_services()
        # 注册路由
        handlers = environment.get_all_handlers()
        # 添加动态路由
        super().__init__(handlers, **config.settings)